<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\widgets\LinkPager;
use yii\helpers\Url;
$this->params['breadcrumbs'][] = $this->title;

?>
<script type="text/javascript">
  $(function(){
    $(".msgLists a").click(function(){
  $.post("",
  {
    name:$(this).attr('name'),
   
  },
  function(data){
    //alert(data);
   if(data){
       window.location.href = '/mycount/detail/'+data+'';
    }
  });
});
  });
</script>
 <script type="text/javascript">
$(function(){
    $(".msgLists li").click(function(){
      //alert($(this).attr('name'));
      $.post('',{'lid':$(this).attr('name')},function(data){
        
       
    })
  })
  })
</script> 
  <script>
   //全部标记为已读
     function qb(){
      
        $.post('',{'qb':'1'},function(data){
        if(data==1){
          window.location.reload();
        }
       
    })
      
     

     
    }
    //单选
    function select_one(_this){
        if(!$(_this).hasClass('selected')){
            $(_this).addClass('selected');
        }else {
            $(_this).removeClass('selected');
        }
      
    }

    //全选
    function select_all(_this){
        if( !$(_this).hasClass('selected') ){
            $('.check-box').each(function(e,item){
                $(item).addClass('selected');
            });
        }else{
            $('.check-box').each(function(e,item){
                $(item).removeClass('selected');
            });
        }
      
    }
     //删除选中的
    function xuanzhong(){
       layer.confirm('您确认要删除吗？', {
          btn: ['确认','取消'], //按钮
          shade: false, //不显示遮罩
          icon:3,   //5
      }, function(){
        var ids = '';
        $('.msgLists .selected').each(function(e, item){
            ids += ','+$(item).siblings('.msgLists a').attr('name');
        });
        $.ajax({
            type: "POST",
            url: "/mycount/delete",
            data: "id="+ids+"&_csrf=<?=Yii::$app->request->getCsrfToken()?>",
            dataType: "json",
            success: function(data){
                if(!data.errNo){
                    layer.msg(data.msg,{time:2000});
                    window.location.reload();
                }else{
                    layer.msg(data.msg,{time:2000});
                    window.location.reload();
                }
            }
        });
      })
      
    }
  
  </script> 

 <div class="mcCont mcgCont">
   
      <div class="right msgCenter">
        <h1 class="tt">消息中心</h1>
        <a style="cursor:pointer" onclick="qb()" class="allReaded inlineBlock">全部标记已读</a><br>
        <span class="firstTt inlineBlock"><span class="selectAll check-box " onclick="select_all(this)"></span>全选</span>
        <ul class="msgLists">
     <?php foreach ($models as $key => $value):?>
           
          <li class="<?= $value->is_read==2?'readed':''?>" name='<?=$value->id?>' style="width:811px;margin-left:30px;">
          <span class="check-box " onclick="select_one(this)""></span>
         <i class="<?= $value->is_read==1?'iconfont icon-xinfeng':'iconfont icon-xinfen'?>"></i>
          <a style="cursor:pointer" name='<?=$value->id?>'>
          <?php echo substr(Html::encode($value->content),0,20)?></a>
         <span class="time right">
          <?= Html::encode($value->create_time) ?>
            
          </span>
          </li>
          
          
          <?php endforeach ?>  
        </ul>
        <br>
        <span class="firstTt inlineBlock"><span class="selectAll check-box" onclick="select_all(this)"></span>全选</span>

        <span class="deleteSelect" onclick="xuanzhong()" style="cursor:pointer">删除</span>
        <br/>
   
   <style type="text/css">
  .pagination li{line-height:25px;margin-left: 1px;float:left;} 
  .pagination li a{color: #999;width:30px;display:block;text-align:center;border-radius: 2px;}
  .pagination .active a{color:#fff;z-index: 2;cursor: default;background-color:#337ab7;border-color: #337ab7;width:30px;height:24px; }
  .fa-angle-left{width:30px;height:24px;border: 2px solid #DDDDDD;text-align:center;line-height:24px;border-radius:5px;}
  .fa-angle-right{width:30px;height:24px;border: 2px solid #DDDDDD;text-align:center;line-height:24px;border-radius:5px;}
</style>
<span class="page right" style="line-height:25px"></span>
<?php
echo LinkPager::widget([
    'pagination' => $pages,
    'maxButtonCount' => 5,
    'options' => ['class' => 'pagination page right'], 
    'nextPageLabel' => '<span class="next inlineBlock"><i class="fa fa-angle-right"></i></span>', 
    'prevPageLabel' => '<span class="pre inlineBlock"><i class="fa fa-angle-left"></i></span>', 
]);
?> 
      </div>

    </div>

  </div>


</div>





</body>
</html>
